package com.zxt.content.copywriting.enums;

/**
 * 文案推送类型 1.私有文案推送 2.公共文案推送
 *
 * @author zxt
 */
public enum PushTypeEnum {

    PRIVATE((byte) 1, "私有文案推送"),
    PUBLIC((byte) 2, "公共文案推送"),
    ;

    private byte value;
    private String desc;

    PushTypeEnum(byte value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public byte getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static boolean exists(Byte status) {
        if (status == null) {
            return false;
        }
        byte s = status.byteValue();
        return exists(s);
    }

    public static boolean exists(byte s) {
        for (PushTypeEnum element : PushTypeEnum.values()) {
            if (element.value == s) {
                return true;
            }
        }
        return false;
    }

    public boolean equal(Byte val) {
        return val == null ? false : val.byteValue() == this.value;
    }

    public static String getDescByValue(Byte value) {
        if (value == null) {
            return "";
        }
        for (PushTypeEnum element : PushTypeEnum.values()) {
            if (element.value == value.byteValue()) {
                return element.desc;
            }
        }
        return "";
    }

    public static Byte getValueByDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (PushTypeEnum element : PushTypeEnum.values()) {
            if (element.desc.equals(desc.trim())) {
                return element.value;
            }
        }
        return null;
    }

}
